package com.kingyun.gpsinspection.purificationservice.services.tdm.innerservice.impl;

import com.kingyun.gpsinspection.purificationservice.dao.mapper.tdm.TaskTypeMapper;
import com.kingyun.gpsinspection.purificationservice.facade.model.tdm.TaskType;
import com.kingyun.gpsinspection.purificationservice.facade.service.tdm.TaskTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by sugongche on 2016/12/12.
 */
@Service
public class TaskTypeServiceImpl implements TaskTypeService {
    private static Logger logger = LoggerFactory.getLogger(TaskTypeServiceImpl.class);

    @Autowired
    private TaskTypeMapper taskTypeMapper;

    public List<TaskType> queryList(){
        List<TaskType> list=taskTypeMapper.queryList();

        return list;
    }

    /**
     * 查询任务类型
     *
     * @return
     */
    @Override
    public List<TaskType> queryTaskType() {
        List<TaskType> returnList = new ArrayList<>();
        List<TaskType> list = taskTypeMapper.queryList();//查询所有的类型
        /*Java8 Streams的应用,低版本不兼容*/
        returnList.addAll(list.stream().filter(taskType -> taskType.getTaskType() < 5).collect(Collectors.toList()));//筛选出前四个类型
        //筛选出前四个类型
        /*for (TaskType taskType : list) {
            if (taskType.getTaskType() < 5) {
                returnList.add(taskType);
            }
        }*/
        return returnList;
    }
}
